<?php
/**
 * File: Area.php
 * User: Mr.Yang
 * Date: 2025/3/31 0031
 * Time: 9:11
 * Note:
 */

namespace app\common\controller;


use think\Controller;
use app\admin\model\Area as AreaModel;

class Area extends Controller
{
    /**
     * Note: 获取地区
     * User: Mr.Yang
     * @param int $pid
     * @return \think\Collection|\think\Model[]
     */
    public static function getAreaByPid($pid = 0)
    {
        $area = AreaModel::where('parentid', '=', $pid)->order('listorder', 'asc')->select();
        return $area;
    }

    public function getArea($areaid)
    {
        if ($areaid) {
            $area = AreaModel::where('parentid', '=', $areaid)->order('listorder', 'asc')->select();
            return json(['code' => 0, 'data' => $area]);
        }
        return json(['code' => 1, 'msg' => '获取失败']);
    }
}